package br.com.gerador.component;

import java.io.FileOutputStream;
import java.util.ArrayList;

import br.com.gerador.icomponent.IGComponent;
import br.com.gerador.icomponent.IGPage;

import com.thoughtworks.xstream.XStream;
	
public class GProcessador {
	private IGPage page;
	
	public GProcessador(IGPage page) {
		super();
		this.page = page;
	}

	public void salvar(){
		ArrayList<GHtmlRender> list = new ArrayList<GHtmlRender>();
		for (IGComponent c :page.getGComponents()) {
			list.add(getGHtmlRender(c));
		}
		
		FileOutputStream f;
		try {
			f = new FileOutputStream("../intranet-app/temp.xml");
			XStream xml = new XStream();
			xml.autodetectAnnotations(true);
			xml.toXML(list,f);
			f.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void abrir(){
		
	}
	
	private GHtmlRender getGHtmlRender(IGComponent c){
		GHtmlRender render = new GHtmlRender();
		return render;
	}
}
